<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>   
    <style>
        * {
          margin: 0;
          padding: 0;
        }
        #box {
            width: 200px;
            height: 300px;
            margin: 200px 200px;
            background-image: url("f540924c2c5bcaf351f6b3da2c10e60c.png");
            position: relative;
        }
        .text {
          width: 150px;
          height: 50px;
          text-align: center;
          line-height: 48px;
          color: #fff;
          font-size: 30px;
          font-weight: 900px;
          position: absolute;
          left: 30px;
          top: 45px;
        }
    
        .hour {
          left: 20px;
        }
    
        .hm {
          left: 70px;
        }
    
        .minute {
          left: 70px;
        }
    
        .ms {
          right: 70px;
        }
    
        .second {
          left: 140px;
        }
    
        .hour,
        .minute,
        .second {
          position: absolute;
          top: 190px;
          color: #fff;
          font-weight: 800;
          font-size: 38px;
          text-align: center;
          line-height: 38px;
          width: 38px;
          height: 38px;
          background: rgb(121, 111, 111);
        }
    
        .hm,
        .ms {
          color: #fff;
          font-size: 20px;
          font-weight: 900px;
          position: absolute;
          bottom: 70px;
        }
    
        .words {
          margin-top: 160px;
          font-size: 18px;
          color: white;
          margin-left: 20px;
          text-align: center;
          position: absolute;
        }
      </style>\  
</head>
<body>
    <div id="box">
        <div class="text">京东秒杀</div>
        <div class="words"><strong>10:00</strong> 点场 距离结束</div>
        <div class="hour"></div>
        <span class="hm">:</span>
        <div class="minute"></div>
        <span class="ms">:</span>
        <div class="second"></div>
      </div>
</body>
<script>
    var hour = document.querySelector(".hour");
    var minute = document.querySelector(".minute");
    var second = document.querySelector(".second");
    var inputTime = +new Date(2021,6,7,10,00,00);
    countDown();
    setInterval(countDown, 1000);
    function countDown() {
      var nowTime = new Date(); 
      var times = (inputTime - nowTime) / 1000; 
      var h = parseInt(times / 60 / 60 % 24);
      h = h < 10 ? '0' + h : h;
      hour.innerHTML = h;
      var m = parseInt(times / 60 % 60);
      m = m < 10 ? "0" + m : m;
      minute.innerHTML = m;
      var s = parseInt(times % 60);
      s = s < 10 ? "0" + s : s;
      second.innerHTML = s;
    }
  </script>
</html>
